import Ajax from '../axios'
const state = {
    errInfo: '',
    teams: null,
    token: '',
    curTeam: null
}

const mutations = {
    // 在axios中提交
    initError(state, errInfo) {
        state.errInfo = errInfo
    },
    initTeams(state, team) {
        state.teams = team
    },
    initToken(state, token) {
        state.token = token
    },
    setCurTeam(state, curTeam) {
        state.curTeam = curTeam
    }
}

const actions = {
    getTeams({ commit }) {
        return Ajax.post('/user/userCompany', {
            type: 2
        }).then(data => {
            commit('setCurTeam', data.data.data[0])
            commit('initTeams', data.data.data)
            return data
        })
    }
}

const getters = {
}

export {
    state,
    mutations,
    actions,
    getters
}
